@extends('Admin.layouts.common')

@section('head')
<script>
    if(top.location != location){
        top.location.reload(true);
    }
</script>
@endsection

@section('content')
    <ul class="sideMenu sideMenu-open">
        <li class="active">
            <a href="/"><i class="glyphicon glyphicon-home"></i>首页</a>
        </li>
        @foreach($admin_menu_list as $root_key=>$r)
            <?php
                $bool = false;
                foreach($admin_rights as $op){
                    if( !empty($r['list']) && array_key_exists($op,$r['list']) ){
                        $bool = true;
                        break;
                    }
                }
            ?>
            @if($bool==true)
            <li>
                <a href="javascript:void(0);" data-href="javascript:void(0);" data-toggle="openMenu">
                    <i class="glyphicon glyphicon-{{ isset($r['icon']) ? $r['icon'] : '' }}"></i>{{ $root_key }}<i class="glyphicon glyphicon-option-horizontal"></i>
                </a>
                <ul class="collapsedMenu">
                    @if(!empty($r['list']))
                    @foreach($r['list'] as $rights=>$menu)
                        @if( in_array($rights,$admin_rights) )
                        <li id="{{$rights}}"><a href="javascript:void(0);" data-href="/{{ admin_menu_url($rights) }}">{{ $menu }}</a></li>
                        @endif
                    @endforeach
                    @endif
                </ul>
            </li>
            @endif
        @endforeach
      
    </ul>
    <div class="container-admin admin-open">
        <header>
            <div class="admin-circle collapse_sidebar" data-title="菜单折叠" data-toggle="tooltip" data-placement="bottom">
                <i class="glyphicon glyphicon-menu-hamburger"></i>
            </div><div class="admin-circle" data-title="访问前台页面" data-toggle="tooltip" data-placement="bottom">
                <a href="{{ config('app.protocol').config('app.url') }}" target="_blank"><i class="glyphicon glyphicon-globe"></i></a>
            </div>
            <div class="admin_account">
                <div class="admin_avatar"></div>
                <a href="javascript:void(0);" data-toggle="adminDropdown" class="admin_name">
                    {{ session('admin.name') }} <i class="glyphicon glyphicon-menu-down"></i>
                </a>
                <ul class="dropdown-menu" id="adminDropdown">
                    <li><a href="javascript:void(0);" data-href="/Profile/edit/{{$admin['id']}}">修改资料</a></li>
                    <li><a href="/Profile/refresh">刷新</a></li>
                    <li><a href="/Auth/logout">注销</a></li>
                </ul>
            </div>
        </header>
        <iframe src="{{$last_url??'/Home/welcome'}}" frameborder="0"></iframe>
    </div>
@endsection